package cn.org.eshow.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 提现记录表
 */
@Entity
@Table(name = "withdraw")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Withdraw extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;//提现记录ID

    @Column(name = "add_time", nullable = false, length = 0)
    private Date addTime = new Date();//添加时间

    @Column(name = "update_time", nullable = false, length = 0)
    private Date updateTime = new Date();//更新时间

    @Column(name = "no")
    private String no;// 订单号

    @Column(length = 20)
    private String way;//提现方式（银行卡，支付宝，会员卡，微信）

    @Column
    private Double price;//提现金额

    @Column
    private String channel;//渠道（支付宝，中国工商银行，微信）

    @Column
    private String name;//名称（姓名，开户名）

    @Column
    private String account;//账号（支付宝账号，银行卡号码）

    @Column
    private Integer state = 0;//状态（0提现中，1已成功，-1失败）

    @Column
    private String content;//说明内容

    @Column
    private String attachment;//附件

    @Column
    private String remark;//备注

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;//用户

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "accountant_user_id")
    private User accountantUser;//会计用户

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getWay() {
        return way;
    }

    public void setWay(String way) {
        this.way = way;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAttachment() {
        return attachment;
    }

    public void setAttachment(String attachment) {
        this.attachment = attachment;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getAccountantUser() {
        return accountantUser;
    }

    public void setAccountantUser(User accountantUser) {
        this.accountantUser = accountantUser;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass())
            return false;
        Withdraw pojo = (Withdraw) o;
        if (id != null ? !pojo.id.equals(id) : pojo.id != null)
            return false;
        if (addTime != null ? !pojo.addTime.equals(addTime) : pojo.addTime != null)
            return false;
        if (updateTime != null ? !pojo.updateTime.equals(updateTime) : pojo.updateTime != null)
            return false;
        if (no != null ? !pojo.no.equals(no) : pojo.no != null)
            return false;
        if (way != null ? !pojo.way.equals(way) : pojo.way != null)
            return false;
        if (price != null ? !pojo.price.equals(price) : pojo.price != null)
            return false;
        if (channel != null ? !pojo.channel.equals(channel) : pojo.channel != null)
            return false;
        if (name != null ? !pojo.name.equals(name) : pojo.name != null)
            return false;
        if (account != null ? !pojo.account.equals(account) : pojo.account != null)
            return false;
        if (state != null ? !pojo.state.equals(state) : pojo.state != null)
            return false;
        if (content != null ? !pojo.content.equals(content) : pojo.content != null)
            return false;
        if (attachment != null ? !pojo.attachment.equals(attachment) : pojo.attachment != null)
            return false;
        if (remark != null ? !pojo.remark.equals(remark) : pojo.remark != null)
            return false;
        if (user != null ? !pojo.user.equals(user) : pojo.user != null)
            return false;
        if (accountantUser != null ? !pojo.accountantUser.equals(accountantUser) : pojo.accountantUser != null)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = result * 31 + (id != null ? id.hashCode() : 0);
        result = result * 31 + (addTime != null ? addTime.hashCode() : 0);
        result = result * 31 + (updateTime != null ? updateTime.hashCode() : 0);
        result = result * 31 + (no != null ? no.hashCode() : 0);
        result = result * 31 + (way != null ? way.hashCode() : 0);
        result = result * 31 + (price != null ? price.hashCode() : 0);
        result = result * 31 + (channel != null ? channel.hashCode() : 0);
        result = result * 31 + (name != null ? name.hashCode() : 0);
        result = result * 31 + (account != null ? account.hashCode() : 0);
        result = result * 31 + (state != null ? state.hashCode() : 0);
        result = result * 31 + (content != null ? content.hashCode() : 0);
        result = result * 31 + (attachment != null ? attachment.hashCode() : 0);
        result = result * 31 + (remark != null ? remark.hashCode() : 0);
        result = result * 31 + (user != null ? user.hashCode() : 0);
        result = result * 31 + (accountantUser != null ? accountantUser.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", this.id)
                .append("addTime", this.addTime)
                .append("updateTime", this.updateTime)
                .append("no", this.no)
                .append("way", this.way)
                .append("price", this.price)
                .append("channel", this.channel)
                .append("name", this.name)
                .append("account", this.account)
                .append("state", this.state)
                .append("content", this.content)
                .append("attachment", this.attachment)
                .append("remark", this.remark)
                .append("user", this.user)
                .append("accountantUser", this.accountantUser)
                .toString();
    }
}
